<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>lesson 24</title>
  <script src="https://unpkg.com/vue@next"></script>
  <style>

    /*入场动画展示*/
    .v-enter-from{
      opacity: 0;
    }
    .v-enter-active{
      transition: opacity 3s ease-out;
    }
    .v-enter-to{
      opacity: 1;
    }

    /*出场动画展示*/
    .v-leave-from{
      opacity: 1;
    }
    .v-leave-active{
      transition: opacity 3s ease-in;
    }
    .v-leave-to{
      opacity: 0;
    }

  </style>
</head>
<body>
  <div id="root"></div>
</body>
<script>
  // 单元素，单组件的入场动画和出场动画
  const app = Vue.createApp({
    data() {
      return {
        show: false,
      }
    },
    methods: {
      handleClick(){
        this.show = !this.show;
      }
    },

    template: `
      <div>
      <transition>
        <div v-if="show">
          Hello Word
        </div>
      </transition>
      <div>
        <button @click="handleClick">切换</button>
      </div>
      </div>
    `
  });
  const vm = app.mount('#root');
</script>
</html>